package com.pacific.sign.biz.service;

import com.pacific.common.request.CommonRequest;
import com.pacific.common.response.CommonResponse;
import com.pacific.sign.biz.service.impl.RoleService;
import com.pacific.sign.biz.wrapper.CommonWrapper;
import com.pacific.sign.biz.wrapper.aop.LogAnnotation;
import com.pacific.sign.model.po.pac.mbg.PacHcRole;
import com.pacific.sign.model.po.pac.request.PacHcRoleRequest;
import com.pacific.sign.model.po.pac.response.PacHcRoleResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by 1 on 2017/6/29.
 */
@Service
public class HcRoleServiceImpl extends CommonWrapper implements HcRoleService {

    @Autowired
    private RoleService roleService;

    @LogAnnotation("角色查询")
    public CommonResponse<PacHcRoleResponse> query(CommonRequest<PacHcRoleRequest> request) {
        CommonResponse<PacHcRoleResponse> response = new CommonResponse<PacHcRoleResponse>();
        try {
            response.setResult(roleService.query(request.getRequestParam()));
            wrapper(response);
        } catch (Exception e) {
            wrapper(response, e);
        }
        return response;
    }

    @LogAnnotation("角色新增")
    public CommonResponse<Integer> insert(CommonRequest<PacHcRole> request) {
        CommonResponse<Integer> response = new CommonResponse<Integer>();
        try {
            response.setResult(roleService.insert(request.getRequestParam()));
            wrapper(response);
        } catch (Exception e) {
            wrapper(response, e);
        }
        return response;
    }

    @LogAnnotation("角色修改")
    public CommonResponse<Integer> update(CommonRequest<PacHcRole> request) {
        CommonResponse<Integer> response = new CommonResponse<Integer>();
        try {
            response.setResult(roleService.update(request.getRequestParam()));
            wrapper(response);
        } catch (Exception e) {
            wrapper(response, e);
        }
        return response;
    }

    @LogAnnotation("角色删除")
    public CommonResponse<Integer> delete(CommonRequest<PacHcRole> request) {
        CommonResponse<Integer> response = new CommonResponse<Integer>();
        try {
            response.setResult(roleService.delete(request.getRequestParam()));
            wrapper(response);
        } catch (Exception e) {
            wrapper(response, e);
        }
        return response;
    }

    @LogAnnotation("角色id查询")
    public CommonResponse<PacHcRole> queryById(CommonRequest<Integer> request) {
        CommonResponse<PacHcRole> response = new CommonResponse<PacHcRole>();
        try {
            response.setResult(roleService.selectById(request.getRequestParam()));
            wrapper(response);
        } catch (Exception e) {
            wrapper(response, e);
        }
        return response;
    }
}
